package com.appbee.core.client.modular.impl;

import javax.inject.Inject;
import javax.inject.Provider;

import com.appbee.core.client.place.INamePlace;
import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class ModulActivityMapper implements ActivityMapper
{
	private final Provider<ActivityProxy> activityProxyProvider;

	@Inject
	public ModulActivityMapper(Provider<ActivityProxy> activityProxyProvider)
	{
		super();
		this.activityProxyProvider = activityProxyProvider;
	}

	@Override
	public Activity getActivity(Place place)
	{
		if (!(place instanceof INamePlace))
			return null;
		INamePlace namePlace = (INamePlace) place;
		ActivityProxy activityProxy = activityProxyProvider.get();
		activityProxy.setPlace(namePlace);
		return activityProxy;
	}

}
